package com.example.exception;

import com.example.until.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @title: MyExceptionHandle
 * @Author wjf
 * @Date: 2022/9/22 15:47
 * @Version 1.0
 */
@ControllerAdvice
public class MyExceptionHandle {

    @ExceptionHandler(ServiceException.class)
    @ResponseBody
    public Result handle(ServiceException se){
        return Result.info(se.getCode(), se.getMessage());
    }
}
